Component({
    properties: {
        item: {
            type: Object,
            value: {}
        },
        index: {
            type: Number,
            value: null
        }
    },
    data: {
        cartTotal: null,
        timer: null
    },
    methods: {
        showGoodDetail: function() {
            this.triggerEvent("show", {
                id: this.data.item.id,
                index: this.data.index
            });
        },
        addCart: function() {
            var t = this;
            this.data.timer && clearTimeout(this.data.timer), this.data.timer = setTimeout(function() {
                t.triggerEvent("add", {
                    id: t.data.item.id,
                    isSpecs: t.data.item.has_option,
                    index: t.data.index
                });
            }, 500);
        },
        onchange: function(t) {
            var i = this;
            this.data.timer && clearTimeout(this.data.timer), this.data.timer = setTimeout(function() {
                i.triggerEvent("change", {
                    id: i.data.item.id,
                    isSpecs: i.data.item.has_option,
                    index: i.data.index,
                    num: t.detail,
                    cartId: i.data.item.card_id
                });
            }, 500);
        }
    }
});